import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'
import type { DataExportAO } from '/@/model/cn/core/tool/ao/DataExportAO'

import sqlStrService from '/@/api/cn/core/kpis/sqlStrService'

import type { SqlStr } from '/@/model/cn/core/kpis/eo/SqlStr'
import type { SqlStrQO } from '/@/model/cn/core/kpis/qo/SqlStrQO'
import type { SqlStrVO } from '/@/model/cn/core/kpis/vo/SqlStrVO'

interface SqlStrState {
}

export const useSqlStrStore = defineStore({
  id: 'sqlStr',
  state: (): SqlStrState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<SqlStr>): Promise<Res<SqlStr>> {
      return new Promise<Res<SqlStr>>((resolve, reject) => {
        sqlStrService.save(param).then((res: AxiosResponse<Res<SqlStr>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<SqlStr>): Promise<Res<SqlStr>> {
      return new Promise<Res<SqlStr>>((resolve, reject) => {
        sqlStrService.saveBatch(param).then((res: AxiosResponse<Res<SqlStr>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<SqlStr>): Promise<Res<SqlStr>> {
      return new Promise<Res<SqlStr>>((resolve, reject) => {
        sqlStrService.update(param).then((res: AxiosResponse<Res<SqlStr>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<SqlStr>): Promise<Res<SqlStr>> {
      return new Promise<Res<SqlStr>>((resolve, reject) => {
        sqlStrService.updateBatch(param).then((res: AxiosResponse<Res<SqlStr>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<SqlStr>): Promise<Res<SqlStr>> {
      return new Promise<Res<SqlStr>>((resolve, reject) => {
        sqlStrService.remove(param).then((res: AxiosResponse<Res<SqlStr>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<SqlStr>): Promise<Res<SqlStr>> {
      return new Promise<Res<SqlStr>>((resolve, reject) => {
        sqlStrService.removeBatch(param).then((res: AxiosResponse<Res<SqlStr>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<SqlStrQO>): Promise<Res<SqlStr>> {
      return new Promise<Res<SqlStr>>((resolve, reject) => {
        sqlStrService.count(param).then((res: AxiosResponse<Res<SqlStr>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<SqlStrQO>): Promise<Res<SqlStr>> {
      return new Promise<Res<SqlStr>>((resolve, reject) => {
        sqlStrService.pk(param).then((res: AxiosResponse<Res<SqlStr>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<SqlStrQO>): Promise<Res<SqlStr>> {
      return new Promise<Res<SqlStr>>((resolve, reject) => {
        sqlStrService.query(param).then((res: AxiosResponse<Res<SqlStr>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<SqlStrQO>): Promise<Res<SqlStr>> {
      return new Promise<Res<SqlStr>>((resolve, reject) => {
        sqlStrService.paging(param).then((res: AxiosResponse<Res<SqlStr>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<SqlStrQO>): Promise<Res<SqlStrVO>> {
      return new Promise<Res<SqlStrVO>>((resolve, reject) => {
        sqlStrService.countVo(param).then((res: AxiosResponse<Res<SqlStrVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<SqlStrQO>): Promise<Res<SqlStrVO>> {
      return new Promise<Res<SqlStrVO>>((resolve, reject) => {
        sqlStrService.pkVo(param).then((res: AxiosResponse<Res<SqlStrVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<SqlStrQO>): Promise<Res<SqlStrVO>> {
      return new Promise<Res<SqlStrVO>>((resolve, reject) => {
        sqlStrService.queryVo(param).then((res: AxiosResponse<Res<SqlStrVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<SqlStrQO>): Promise<Res<SqlStrVO>> {
      return new Promise<Res<SqlStrVO>>((resolve, reject) => {
        sqlStrService.pagingVo(param).then((res: AxiosResponse<Res<SqlStrVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    dataImport(param: Param<string>): Promise<Res<SqlStr>> {
      return new Promise<Res<SqlStr>>((resolve, reject) => {
        sqlStrService.dataImport(param).then((res: AxiosResponse<Res<SqlStr>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    dataExport(param: Param<DataExportAO<SqlStrQO>>): Promise<Res<string>> {
      return new Promise<Res<string>>((resolve, reject) => {
        sqlStrService.dataExport(param).then((res: AxiosResponse<Res<string>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function useSqlStrStoreWithout() {
  return useSqlStrStore(store)
}
